"""Definition of the building content type
"""

from zope.interface import implements

from Products.Archetypes import atapi
from Products.ATContentTypes.content import base
from Products.ATContentTypes.content import schemata

# -*- Message Factory Imported Here -*-
from my315ok.xtinfocontent import xtinfocontentMessageFactory as _

from my315ok.xtinfocontent.interfaces import Ibuilding
from my315ok.xtinfocontent.config import PROJECTNAME

buildingSchema = schemata.ATContentTypeSchema.copy() + atapi.Schema((

    # -*- Your Archetypes field definitions here ... -*-

    atapi.StringField(
        'name',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"build name"),
            description=_(u""),
        ),
        required=True,
    ),


    atapi.StringField(
        'district',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"build locate at district"),
            description=_(u""),
        ),
    ),


    atapi.StringField(
        'types',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"rooms type"),
            description=_(u""),
        ),
    ),


    atapi.StringField(
        'decorations',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"decoration status"),
            description=_(u""),
        ),
    ),


    atapi.StringField(
        'bdeveloper',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"build developer"),
            description=_(u""),
        ),
    ),


    atapi.ImageField(
        'cert',
        storage=atapi.AnnotationStorage(),
        widget=atapi.ImageWidget(
            label=_(u"certification for sale"),
            description=_(u""),
        ),
        validators=('isNonEmptyFile'),
    ),


    atapi.StringField(
        'traffic',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"traffic"),
            description=_(u""),
        ),
    ),


    atapi.StringField(
        'baddr',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"address of build"),
            description=_(u""),
        ),
    ),


    atapi.StringField(
        'saddr',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"address for sales"),
            description=_(u""),
        ),
    ),


))

# Set storage on fields copied from ATContentTypeSchema, making sure
# they work well with the python bridge properties.

buildingSchema['title'].storage = atapi.AnnotationStorage()
buildingSchema['description'].storage = atapi.AnnotationStorage()

schemata.finalizeATCTSchema(buildingSchema, moveDiscussion=False)


class building(base.ATCTContent):
    """publish information of the building for sales"""
    implements(Ibuilding)

    meta_type = "building"
    schema = buildingSchema

    title = atapi.ATFieldProperty('title')
    description = atapi.ATFieldProperty('description')

    # -*- Your ATSchema to Python Property Bridges Here ... -*-
    name = atapi.ATFieldProperty('name')

    district = atapi.ATFieldProperty('district')

    types = atapi.ATFieldProperty('types')

    decorations = atapi.ATFieldProperty('decorations')

    bdeveloper = atapi.ATFieldProperty('bdeveloper')

    cert = atapi.ATFieldProperty('cert')

    traffic = atapi.ATFieldProperty('traffic')

    baddr = atapi.ATFieldProperty('baddr')

    saddr = atapi.ATFieldProperty('saddr')


atapi.registerType(building, PROJECTNAME)
